Skip to content

fix: Allow Parse Server startup without optional push adapter#10446

Open
ga262 wants to merge 5 commits intoparse-community:alphafrom
ga262:fix/optional-push-adapter
Open

fix: Allow Parse Server startup without optional push adapter#10446
ga262 wants to merge 5 commits intoparse-community:alphafrom
ga262:fix/optional-push-adapter

Conversation

@ga262
Copy link
Copy Markdown

@ga262 ga262 commented Apr 21, 2026

Issue

Parse Server currently declares @parse/push-adapter as an optional dependency, but startup still attempts to load it unconditionally in the push controller path. This creates a mismatch between package metadata and runtime behavior.

Current behavior

  • If @parse/push-adapter is not installed:
    • startup may fail due to default push adapter import
    • this can happen even when push is not explicitly configured
  • If push is configured without a custom push.adapter, startup fails with a generic module resolution error

Expected behavior

  • When push is not configured, Parse Server should start even if @parse/push-adapter is absent
  • When push is configured but no custom adapter is provided, Parse Server should fail with a clear actionable error indicating that @parse/push-adapter must be installed (or push.adapter must be provided)

Why this matters

  • aligns runtime behavior with optionalDependencies intent
  • avoids forcing optional push dependencies in deployments that do not use push notifications
  • improves DX for minimal/containerized installs (e.g. --omit=optional)
  • preserves explicit failure when push is actually requested but misconfigured

Summary

  • handle missing @parse/push-adapter when loading the default push adapter
  • allow server startup when push is not configured and the optional adapter is not installed
  • throw a clear startup error when push is configured but neither @parse/push-adapter nor a custom push.adapter is available
  • only create PushWorker when push support is enabled

Test plan

  • npm run build
  • npm run testonly spec/index.spec.js
  • npm run testonly spec/AdapterLoader.spec.js
  • added test: startup succeeds when push is undefined and @parse/push-adapter is missing
  • added test: startup fails with explicit error when push is configured and @parse/push-adapter is missing

Summary by CodeRabbit

  • New Features

    • Push adapter is now optional—installed only when needed, reducing default install footprint.
  • Improvements

    • Clearer error messages when push is configured but its adapter is not installed.
    • Push worker only starts when push support is available.
  • Tests

    • Added tests covering missing push-adapter scenarios and the clearer error behavior.

ga262 added 3 commits April 21, 2026 16:29
Added a function to check for missing push adapter module and handle errors accordingly.

Signed-off-by: ga262 <[email protected]>
Removed '@parse/push-adapter' from dependencies and added it to optionalDependencies.

Signed-off-by: ga262 <[email protected]>
@parse-github-assistant
Copy link
Copy Markdown

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant Bot changed the title fix: allow Parse Server startup without optional push adapter fix: Allow Parse Server startup without optional push adapter Apr 21, 2026
@parse-github-assistant
Copy link
Copy Markdown

parse-github-assistant Bot commented Apr 21, 2026

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 461485b3-1214-45c0-b13f-0c8e12fe7f31

📥 Commits

Reviewing files that changed from the base of the PR and between 2d96a6e and b9e3e80.

📒 Files selected for processing (1)
  • package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

📝 Walkthrough

Walkthrough

Moved @parse/push-adapter to optionalDependencies, added detection for missing push-adapter load errors, changed push controller to only spawn the worker when push support exists, and added two tests covering missing-adapter behaviors. (45 words)

Changes

Push adapter optionalization and handling

Layer / File(s) Summary
Dependency Change
package.json
Removed @parse/push-adapter from dependencies and added it to optionalDependencies (8.4.0).
Error Detection / Core Logic
src/Controllers/index.js
Added isPushAdapterModuleMissing(error); wrapped loadModule('@parse/push-adapter') in try/catch to rethrow unrelated errors and produce a clearer configuration error when the adapter is missing and push is configured; only create PushWorker when disablePushWorker is false and hasPushSupport is true.
Tests
spec/index.spec.js
Added two tests that simulate @parse/push-adapter being absent: one verifies hasPushSupport becomes false when push is undefined; the other verifies reconfigureServer rejects with a clear error when push: {} is configured but the adapter is missing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • mtrezza
🚥 Pre-merge checks | ✅ 5 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Engage In Review Feedback ❓ Inconclusive GitHub PR review comments and feedback discussions are stored on GitHub's servers, not in the git repository. Cannot determine if PR author engaged with feedback without accessing the GitHub PR directly. Access GitHub PR #10446 directly to review the Conversation and Files changed tabs to verify whether the PR author responded to feedback, made commits addressing feedback, or received reviewer acknowledgments.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title begins with the required 'fix:' prefix and accurately describes the main change: allowing Parse Server startup without the optional push adapter.
Description check ✅ Passed The PR description covers the Issue section (with current/expected behavior), Approach/Summary section, and Test plan section. All major sections are present and adequately filled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Check ✅ Passed Security review confirms no problematic code patterns. Hardcoded module paths, safe error validation, and secure error handling with no user-input interpolation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.2.525)
package.json

2026-05-02 10:19:06,280 [MainThread ] [ERROR] Template file not found: package.json
2026-05-02 10:19:06,287 [MainThread ] [ERROR] Template file not found: package.json
2026-05-02 10:19:06,290 [MainThread ] [ERROR] Template file not found: package.json
2026-05-02 10:19:06,345 [MainThread ] [ERROR] Failed to invoke function /usr/local/lib/python3.11/dist-packages/checkov/common/runners/object_runner. with package.json
Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/checkov/common/parallelizer/parallel_runner.py", line 88, in func_wrapper
result = original_func(item)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/checkov/common/runners/object_runner.py", line 74, in
results = parallel_runner.run_function(lambda f: (f, self._parse_file(f)), files_to_load)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/checkov/ope

... [truncated 2548 characters] ...

k__)
FileNotFoundError: [Errno 2] No such file or directory: 'package.json'
2026-05-02 10:19:06,403 [MainThread ] [ERROR] Exception traceback:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/checkov/main.py", line 647, in run
self.scan_reports = runner_registry.run(
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/checkov/common/runners/runner_registry.py", line 177, in run
for result in parallel_runner_results:
File "/usr/local/lib/python3.11/dist-packages/checkov/common/parallelizer/parallel_runner.py", line 118, in _run_function_multiprocess_fork
raise v.internal_exception.with_traceback(v.internal_exception.traceback)
FileNotFoundError: [Errno 2] No such file or directory: 'package.json'


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/Controllers/index.js (1)

172-201: ⚠️ Potential issue | 🟠 Major

Only load the default push adapter when it is actually needed.

Line 191 unconditionally imports the optional default adapter even when push is unset or a custom push.adapter is provided. This can cause startup to fail unnecessarily when the adapter is not used. Additionally, the error detection at line 176 using message.includes('@parse/push-adapter') can misclassify transitive dependency failures from within @parse/push-adapter as a missing package if the error message path happens to contain that string.

Move the import into the conditional block that only executes when actually needed:

Suggested fix
 function isPushAdapterModuleMissing(error: any): boolean {
   const message = `${error?.message || error || ''}`;
   const hasMissingCode =
     error?.code === 'ERR_MODULE_NOT_FOUND' || error?.code === 'MODULE_NOT_FOUND';
-  return hasMissingCode && message.includes('@parse/push-adapter');
+  return (
+    hasMissingCode &&
+    /Cannot find (?:package|module) ['"]@parse\/push-adapter['"]/.test(message)
+  );
 }
 
   // Pass the push options too as it works with the default
   let ParsePushAdapter;
-  try {
-    ParsePushAdapter = await loadModule('@parse/push-adapter');
-  } catch (error) {
-    if (!isPushAdapterModuleMissing(error)) {
-      throw error;
-    }
-    if (push && !pushOptions.adapter) {
+  if (push && !pushOptions.adapter) {
+    try {
+      ParsePushAdapter = await loadModule('@parse/push-adapter');
+    } catch (error) {
+      if (!isPushAdapterModuleMissing(error)) {
+        throw error;
+      }
       throw new Error(
         'Push is configured but the optional dependency "@parse/push-adapter" is not installed. Install "@parse/push-adapter" or configure "push.adapter".'
       );
     }
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Controllers/index.js` around lines 172 - 201, The code currently calls
loadModule('@parse/push-adapter') unconditionally and uses
isPushAdapterModuleMissing(error) which naively checks
message.includes('@parse/push-adapter'), causing unnecessary startup failures
and false positives; update getPushController so ParsePushAdapter is only loaded
when push is truthy and pushOptions.adapter is not provided (i.e. move the await
loadModule('@parse/push-adapter') call inside the conditional that checks if
push && !pushOptions.adapter), and harden isPushAdapterModuleMissing(error) to
detect a missing package more precisely by checking error.code for
'ERR_MODULE_NOT_FOUND' or 'MODULE_NOT_FOUND' and matching the error message
against a stricter pattern that looks for "Cannot find module" (or the module
name quoted) specifically for '@parse/push-adapter' rather than a simple
substring match.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/Controllers/index.js`:
- Around line 172-201: The code currently calls
loadModule('@parse/push-adapter') unconditionally and uses
isPushAdapterModuleMissing(error) which naively checks
message.includes('@parse/push-adapter'), causing unnecessary startup failures
and false positives; update getPushController so ParsePushAdapter is only loaded
when push is truthy and pushOptions.adapter is not provided (i.e. move the await
loadModule('@parse/push-adapter') call inside the conditional that checks if
push && !pushOptions.adapter), and harden isPushAdapterModuleMissing(error) to
detect a missing package more precisely by checking error.code for
'ERR_MODULE_NOT_FOUND' or 'MODULE_NOT_FOUND' and matching the error message
against a stricter pattern that looks for "Cannot find module" (or the module
name quoted) specifically for '@parse/push-adapter' rather than a simple
substring match.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 950bd482-0f92-4d9f-b1b7-633395bf13d3

📥 Commits

Reviewing files that changed from the base of the PR and between 0980ab1 and 7954250.

📒 Files selected for processing (3)
  • package.json
  • spec/index.spec.js
  • src/Controllers/index.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants